package com.aaa.mapper;

import com.aaa.entity.OvertimeApplication;
import org.apache.ibatis.annotations.*;

/**
 * 残業申請数据访问接口
 * 使用MyBatis注解方式实现SQL映射
 */
@Mapper
public interface ApplicationMapper {
    /**
     * 插入新的残業申請
     *
     * @param overtimeApplication 申请信息实体
     * @return 影响的行数
     */
    @Insert("INSERT INTO application(" +
            "user_name, user_id, start_time, end_time, " +
            "is_internal, location, reason, work_number, " +
            "sub_work_number, initiator_id, status" +
            ") VALUES (" +
            "#{userName}, #{userId}, #{startTime}, #{endTime}, " +
            "#{isInternal}, #{location}, #{reason}, #{workNumber}, " +
            "#{subWorkNumber}, #{initiatorId}, #{status}" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(OvertimeApplication overtimeApplication);
}